
import { uploadData, getPosition, getStruct, pushRateToList, readExel } from '../batch'

const conf={
    1: {
        url: "bath/life-illness-questions",
        idName: "lifeIllnessInsuranceId",
        proName:"lifeIllnessInsuranceName"
    }, // 终身重疾险
    2: {
        url:"bath/pr-car-questions",
        idName:"prCarInsuranceId",
        proName:"prCarInsuranceName"
    }, // 私家车意外险
    3: {
        url:"bath/re-illness-questions",
        idName:"reIllnessInsuranceId",
        proName:"reIllnessInsuranceName"
    }, // 定期重疾险
    4: {
        url:"bath/re-life-rates",
        idName:"regularLifeInsuranceId",
        proName:"regularLifeInsuranceName"
    }, // 定期寿险
}

module.exports = function (params) {

    let exel = getStruct(params.downloadUrl);
    let exelList = [];
    let currentConf=conf[params.insureId]

    console.log("批量录入了..........")

    readExel({
        lines: exel.lines,
        cols: exel.columns,
        table: exel.table,
        eachLine(arr) {
            var row = {
                'qInfo': arr[0],
                'aInfo': arr[1],
            }

            row[currentConf.idName]=arr[2]
            row[currentConf.proName]=null
            exelList.push(row);

        }
    })

    console.log('-----------------解析数据-----\n\n',currentConf.url,exelList)

    return uploadData({
        url: currentConf.url,
        data: exelList,
        successData: {
            code:1
        },
        errData: {

        },
        token: params.token
    })
}